package com.a.basis.testexpand;
//                      数组的扩容
public class TestExpand {
    public static void main(String[] args) {
        //原数组
        int[] oldArray=new int[]{1,2,3,4,5};
        //创建比原数组更大的新数组
        int[] newArray=new int[oldArray.length*2];
        //将原来数组的内同复制到新数组
        for (int i=0;i<oldArray.length;i++){
            newArray[i]=oldArray[i];
        }
        //访问新数组的元素
        for (int i = 0; i < newArray.length; i++) {
            System.out.print(newArray[i]+"\t");
        }
    }
}
